'''
Created on 28/07/2010

@author: eh01
'''
import unittest
from adaptor.services.adaptor_admin_service import AdaptorAdminService
from datastore.uri import Uri
from datastore.spaces import Spaces
from datastore.resource import Resource, ResourceDict
import datetime

class AdaptorAdminServiceTest(unittest.TestCase):


    def setUp(self):
        pass


    def tearDown(self):
        pass

    def stub_do_ra_list_update_success(self, spaces):
        rs = Resource(type="temp")
        return rs
    
    def stub_do_ra_list_update_fail(self, spaces):
        rs = Resource(type="temp")
        rs.error = "Error occured"
        return rs
    
    def stub_do_user_list_update_success(self, spaces):
        rs = Resource(type="temp")
        return rs
    
    def stub_do_user_list_update_fail(self, spaces):
        rs = Resource(type="temp")
        rs.error = "Error occured"
        return rs    
        
    def test_cb_start(self):
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        adaptor_admin_service.cb_start(None, None, None)
        self.assertEquals(adaptor_admin_service.cb_admin_options, spaces.process[Uri('external:adaptor/admin')][0])
        self.assertEquals(adaptor_admin_service.cb_view_spear_connection_status_get, spaces.process[Uri('external:adaptor/admin/view-spear-connection-status')][0])
        self.assertEquals(adaptor_admin_service.cb_refresh_ra_and_user_list_get, spaces.process[Uri('external:adaptor/admin/refresh-ra-and-user-list')][0])
        self.assertEquals(adaptor_admin_service.cb_refresh_ra_and_user_list_post, spaces.process[Uri('internal:adaptor/admin/refresh-ra-and-user-list/')][0])
        self.assertEquals(adaptor_admin_service.cb_view_spear_cps_interaction_activity, spaces.process[Uri('external:adaptor/admin/view-spear-cps-interaction-activity')][0])
        self.assertEquals(adaptor_admin_service.cb_configure_spear_adaptor_get, spaces.process[Uri('external:adaptor/admin/configure-spear-adaptor')][0])
        
    def test_cb_admin_options_get(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        res = adaptor_admin_service.cb_admin_options(None, Spaces.ACTION_GET, None)
        self.assertEqual(Uri("term:eplanning/adaptor/admin/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.SPEAR_ADAPTOR_ADMINISTRATION_HEADER, res.h1_header)
        
    def test_cb_admin_options_exists(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_admin_options(None, Spaces.ACTION_EXISTS, None)
        self.assertTrue(ret)
        
    def test_cb_admin_options_delete(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_admin_options(None, Spaces.ACTION_DELETE, None)
        self.assertEqual(None, ret)
        
    def test_cb_admin_options_remove(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        res = adaptor_admin_service.cb_admin_options(None, Spaces.ACTION_REMOVE, None)
        self.assertEqual(None, res)
        
    def test_cb_admin_options_update(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_admin_options(None, Spaces.ACTION_UPDATE, None)
        self.assertEqual(None, uri)
        
    def test_cb_admin_options_put(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_admin_options(None, Spaces.ACTION_PUT, None)
        self.assertEqual(None, uri)        
        
    def test_cb_admin_options_find(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        lst = adaptor_admin_service.cb_admin_options(None, Spaces.ACTION_FIND, None)
        self.assertEqual(None, lst) 
        
    def test_cb_view_spear_connection_status_get_get(self):
        date = datetime.datetime.now().strftime("%Y%m%dT%H%M%S")
        connection_up = True
        rs = Resource(type="term:eplanning/spear/a2pspear_service/a2pspearstatus")
        rs.date = date
        rs.connection_up = connection_up
        spaces=Spaces()
        spaces.put(Uri("internal:eplanning/spear/a2pspear_service/a2pspearstatus"), rs)
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = adaptor_admin_service.cb_view_spear_connection_status_get(None, Spaces.ACTION_GET, None)
        self.assertEqual(Uri("term:eplanning/adaptor/view-spear-connection-status/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.VIEW_SPEAR_CONNECTION_STATUS_HEADER, res.h1_header)
        self.assertEqual(date, res.date)
        self.assertEqual(connection_up, res.connection_up)
        
    def test_cb_view_spear_connection_status_get_exists(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_view_spear_connection_status_get(None, Spaces.ACTION_EXISTS, None)
        self.assertTrue(ret)
        
    def test_cb_view_spear_connection_status_get_delete(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_view_spear_connection_status_get(None, Spaces.ACTION_DELETE, None)
        self.assertEqual(None, ret)
        
    def test_cb_view_spear_connection_status_get_remove(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        res = adaptor_admin_service.cb_view_spear_connection_status_get(None, Spaces.ACTION_REMOVE, None)
        self.assertEqual(None, res)
        
    def test_cb_view_spear_connection_status_get_update(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_view_spear_connection_status_get(None, Spaces.ACTION_UPDATE, None)
        self.assertEqual(None, uri)
        
    def test_cb_view_spear_connection_status_get_put(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_view_spear_connection_status_get(None, Spaces.ACTION_PUT, None)
        self.assertEqual(None, uri)        
        
    def test_cb_view_spear_connection_status_get_find(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        lst = adaptor_admin_service.cb_view_spear_connection_status_get(None, Spaces.ACTION_FIND, None)
        self.assertEqual(None, lst)

    def test_cb_refresh_ra_and_user_list_list_get_get(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        res = adaptor_admin_service.cb_refresh_ra_and_user_list_get(None, Spaces.ACTION_GET, None)
        self.assertEqual(Uri("term:eplanning/adaptor/refresh-ra-and-user-list/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.REFRESH_RA_AND_USER_LIST_HEADER, res.h1_header)
        
    def test_cb_refresh_ra_and_user_list_get_exists(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_refresh_ra_and_user_list_get(None, Spaces.ACTION_EXISTS, None)
        self.assertTrue(ret)
        
    def test_cb_refresh_ra_and_user_list_get_delete(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_refresh_ra_and_user_list_get(None, Spaces.ACTION_DELETE, None)
        self.assertEqual(None, ret)
        
    def test_cb_refresh_ra_and_user_list_get_remove(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        res = adaptor_admin_service.cb_refresh_ra_and_user_list_get(None, Spaces.ACTION_REMOVE, None)
        self.assertEqual(None, res)
        
    def test_cb_refresh_ra_and_user_list_get_update(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_refresh_ra_and_user_list_get(None, Spaces.ACTION_UPDATE, None)
        self.assertEqual(None, uri)
        
    def test_cb_refresh_ra_and_user_list_get_put(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_refresh_ra_and_user_list_get(None, Spaces.ACTION_PUT, None)
        self.assertEqual(None, uri)        
        
    def test_cb_refresh_ra_and_user_list_get_find(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        lst = adaptor_admin_service.cb_refresh_ra_and_user_list_get(None, Spaces.ACTION_FIND, None)
        self.assertEqual(None, lst)
        
    def test_cb_refresh_ra_and_user_list_post_get(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_GET, None)
        self.assertEqual(None, res)
        
    def test_cb_refresh_ra_and_user_list_post_exists(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        ret = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_EXISTS, None)
        self.assertFalse(ret)
        
    def test_cb_refresh_ra_and_user_list_post_delete(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        ret = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_DELETE, None)
        self.assertEqual(None, ret)
        
    def test_cb_refresh_ra_and_user_list_post_remove(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_REMOVE, None)
        self.assertEqual(None, res)
        
    def test_cb_refresh_ra_and_user_list_post_update(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        uri = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_UPDATE, None)
        self.assertEqual(None, uri)
        
    def test_cb_refresh_ra_and_user_list_post_put_ra_list_success(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = Resource(type="term:base/services/http/post")
        res.form_fields = {AdaptorAdminService.RAS:'on'}
        adaptor_admin_service.do_ra_list_update = self.stub_do_ra_list_update_success
        uri = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_PUT, res)
        self.assertEqual(Uri('dummy/test/response'), uri)
        res = spaces.get(uri)
        self.assertEquals(Uri("term:eplanning/adaptor/refresh-ra-and-user-list/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.REFRESH_RA_AND_USER_LIST_HEADER, res.h1_header)
        self.assertEqual(AdaptorAdminService.REFRESH_SUCCESSFUL, res.message)
        
    def test_cb_refresh_ra_and_user_list_post_put_ra_list_fail(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = Resource(type="term:base/services/http/post")
        res.form_fields = {AdaptorAdminService.RAS:'on'}
        adaptor_admin_service.do_ra_list_update = self.stub_do_ra_list_update_fail
        uri = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_PUT, res)
        self.assertEqual(Uri('dummy/test/response'), uri)
        res = spaces.get(uri)
        self.assertEquals(Uri("term:eplanning/adaptor/refresh-ra-and-user-list/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.REFRESH_RA_AND_USER_LIST_HEADER, res.h1_header)
        self.assertEqual(AdaptorAdminService.REFRESH_FAILED, res.error)  

    def test_cb_refresh_ra_and_user_list_post_put_user_list_success(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = Resource(type="term:base/services/http/post")
        res.form_fields = {AdaptorAdminService.USERS:'on'}
        adaptor_admin_service.do_user_list_update = self.stub_do_user_list_update_success
        uri = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_PUT, res)
        self.assertEqual(Uri('dummy/test/response'), uri)
        res = spaces.get(uri)
        self.assertEquals(Uri("term:eplanning/adaptor/refresh-ra-and-user-list/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.REFRESH_RA_AND_USER_LIST_HEADER, res.h1_header)
        self.assertEqual(AdaptorAdminService.REFRESH_SUCCESSFUL, res.message)
        
    def test_cb_refresh_ra_and_user_list_post_put_user_list_fail(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = Resource(type="term:base/services/http/post")
        res.form_fields = {AdaptorAdminService.USERS:'on'}
        adaptor_admin_service.do_user_list_update = self.stub_do_user_list_update_fail
        uri = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_PUT, res)
        self.assertEqual(Uri('dummy/test/response'), uri)
        res = spaces.get(uri)
        self.assertEquals(Uri("term:eplanning/adaptor/refresh-ra-and-user-list/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.REFRESH_RA_AND_USER_LIST_HEADER, res.h1_header)
        self.assertEqual(AdaptorAdminService.REFRESH_FAILED, res.error)          
        
    def test_cb_refresh_ra_and_user_list_post_put_response(self):
        uri = Uri("dummy/test/response")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_PUT, None)
        self.assertEqual(None, res)                        
        
    def test_cb_refresh_ra_and_user_list_post_find(self):
        uri = Uri("dummy/test")
        spaces=Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        lst = adaptor_admin_service.cb_refresh_ra_and_user_list_post(uri, Spaces.ACTION_FIND, None)
        self.assertEqual(None, lst)

    def test_cb_view_spear_cps_interaction_activity_get(self):
        log_entries = [("Message1", datetime.datetime.now().strftime("%Y%m%dT%H%M%S")),("Message2", datetime.datetime.now().strftime("%Y%m%dT%H%M%S")), ("Message3", datetime.datetime.now().strftime("%Y%m%dT%H%M%S"))]
        rs = Resource(type="term:base/services/logger/logs")
        rs.log_entries = log_entries 
        spaces = Spaces()
        spaces.put(Uri('internal:base/services/logger/logs'), rs)
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = adaptor_admin_service.cb_view_spear_cps_interaction_activity(None, Spaces.ACTION_GET, None)
        self.assertEqual(Uri("term:eplanning/adaptor/view-spear-cps-interaction-activity/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.VIEW_SPEAR_CPS_INTERACTION_ACTIVITY_HEADER, res.h1_header)
        self.assertEqual(log_entries, res.log_entries)
        
    def test_cb_view_spear_cps_interaction_activity_exists(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_view_spear_cps_interaction_activity(None, Spaces.ACTION_EXISTS, None)
        self.assertTrue(ret)
        
    def test_cb_view_spear_cps_interaction_activity_delete(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_view_spear_cps_interaction_activity(None, Spaces.ACTION_DELETE, None)
        self.assertEqual(None, ret)
        
    def test_cb_view_spear_cps_interaction_activity_remove(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        res = adaptor_admin_service.cb_view_spear_cps_interaction_activity(None, Spaces.ACTION_REMOVE, None)
        self.assertEqual(None, res)
        
    def test_cb_view_spear_cps_interaction_activity_update(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_view_spear_cps_interaction_activity(None, Spaces.ACTION_UPDATE, None)
        self.assertEqual(None, uri)
        
    def test_cb_view_spear_cps_interaction_activity_put(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_view_spear_cps_interaction_activity(None, Spaces.ACTION_PUT, None)
        self.assertEqual(None, uri)        
        
    def test_cb_view_spear_cps_interaction_activity_find(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        lst = adaptor_admin_service.cb_view_spear_cps_interaction_activity(None, Spaces.ACTION_FIND, None)
        self.assertEqual(None, lst)
        
    def test_cb_configure_spear_adaptor_get_get(self):
        spaces = Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = adaptor_admin_service.cb_configure_spear_adaptor_get(None, Spaces.ACTION_GET, None)
        self.assertEqual(Uri("term:eplanning/adaptor/configure-spear-adaptor/get/data"), res.get_type())
        self.assertEqual(AdaptorAdminService.CONFIGURE_SPEAR_ADAPTOR_HEADER, res.h1_header)
        
    def test_cb_configure_spear_adaptor_get_exists(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_configure_spear_adaptor_get(None, Spaces.ACTION_EXISTS, None)
        self.assertTrue(ret)
        
    def test_cb_configure_spear_adaptor_get_delete(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_configure_spear_adaptor_get(None, Spaces.ACTION_DELETE, None)
        self.assertEqual(None, ret)
        
    def test_cb_configure_spear_adaptor_get_remove(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        res = adaptor_admin_service.cb_configure_spear_adaptor_get(None, Spaces.ACTION_REMOVE, None)
        self.assertEqual(None, res)
        
    def test_cb_configure_spear_adaptor_get_update(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_configure_spear_adaptor_get(None, Spaces.ACTION_UPDATE, None)
        self.assertEqual(None, uri)
        
    def test_cb_configure_spear_adaptor_get_put(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        uri = adaptor_admin_service.cb_configure_spear_adaptor_get(None, Spaces.ACTION_PUT, None)
        self.assertEqual(None, uri)        
        
    def test_cb_configure_spear_adaptor_get_find(self):
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        lst = adaptor_admin_service.cb_configure_spear_adaptor_get(None, Spaces.ACTION_FIND, None)
        self.assertEqual(None, lst)        

    def test_cb_configure_spear_adaptor_post_get(self):
        uri = Uri("dummy/test")
        spaces = Spaces()
        adaptor_admin_service = AdaptorAdminService(spaces, uri=Uri())
        res = adaptor_admin_service.cb_configure_spear_adaptor_post(uri, Spaces.ACTION_GET, None)
        self.assertEqual(None, res)
        
    def test_cb_configure_spear_adaptor_post_exists(self):
        uri = Uri("dummy/test")
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_configure_spear_adaptor_post(uri, Spaces.ACTION_EXISTS, None)
        self.assertFalse(ret)
        
    def test_cb_configure_spear_adaptor_post_delete(self):
        uri = Uri("dummy/test")
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        ret = adaptor_admin_service.cb_configure_spear_adaptor_post(uri, Spaces.ACTION_DELETE, None)
        self.assertEqual(None, ret)
        
    def test_cb_configure_spear_adaptor_post_remove(self):
        uri = Uri("dummy/test")
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        res = adaptor_admin_service.cb_configure_spear_adaptor_post(uri, Spaces.ACTION_REMOVE, None)
        self.assertEqual(None, res)
        
    def test_cb_configure_spear_adaptor_post_update(self):
        uri = Uri("dummy/test")
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        response_uri = adaptor_admin_service.cb_configure_spear_adaptor_post(uri, Spaces.ACTION_UPDATE, None)
        self.assertEqual(None, response_uri)
        
    def test_cb_configure_spear_adaptor_post_put(self):
        service_url = Uri("internal:base/config/eplanning/spear/a2pspear_service")
        config_rs = Resource(type='term:base/runtime/configuration')
        statics = ResourceDict()
        statics.spear_username = ""
        statics.spear_password = ""
        statics.hostname = ""
        config_rs.services = ResourceDict()
        service_rs = ResourceDict()
        service_rs.options = ResourceDict()
        service_rs.options.statics = statics
        config_rs.services['eplanning/spear/a2pspear_service'] = service_rs
        res_post = Resource(type='term:base/services/http/post')
        res_post.form_fields = {AdaptorAdminService.SPEAR_USERNAME:'1',
                                AdaptorAdminService.SPEAR_PASSWORD:'2',
                                AdaptorAdminService.SPEAR_HOSTNAME:'3'}
        uri = Uri("dummy/test")
        spaces=Spaces()
        spaces.put(service_url, config_rs)
        adaptor_admin_service = AdaptorAdminService(spaces=spaces, uri=Uri())
        response_uri = adaptor_admin_service.cb_configure_spear_adaptor_post(uri, Spaces.ACTION_PUT, res_post)
        self.assertEqual(uri.response, response_uri)
        res = spaces.get(response_uri)
        self.assertEqual(AdaptorAdminService.CONFIGURE_SPEAR_ADAPTOR_HEADER, res.h1_header)
        self.assertEqual(AdaptorAdminService.CONFIGURATIONS_SAVED, res.message)
        config_rs = spaces.get(service_url)
        # check it has updated the configurations
        self.assertEqual('1', config_rs.services['eplanning/spear/a2pspear_service'].options.statics.spear_username)
        self.assertEqual('2', config_rs.services['eplanning/spear/a2pspear_service'].options.statics.spear_password)
        self.assertEqual('3', config_rs.services['eplanning/spear/a2pspear_service'].options.statics.hostname)
        
    def test_cb_configure_spear_adaptor_post_find(self):
        uri = Uri("dummy/test")
        adaptor_admin_service = AdaptorAdminService(spaces=Spaces(), uri=Uri())
        lst = adaptor_admin_service.cb_configure_spear_adaptor_post(uri, Spaces.ACTION_FIND, None)
        self.assertEqual(None, lst)
                     
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()